<?php
  // 预设password,和gitee webhook里填写一样的
  $pwd="yourpasswd";
  // 设置项目路径
  $projpath="/var/proj/yourprojpath";
  // 待完善,暂时用不到
  // $rqip=$_SERVER['REMOTE_ADDR'];

  // 简单 处理一下非POST请求
  if($_SERVER['REQUEST_METHOD']==='GET'){
    echo('wa ooo ~, missing~~~');
    $ipframe='<div ><iframe src="http://2017.ip138.com/ic.asp" rel="nofollow" style="width:400px;height:20px;" scrolling="no" frameborder="0"></iframe></div>';
    echo($ipframe);

    if($_GET['token']==="abc"){
      // $cmd="cd $projpath && ls";
      // var_dump(shell_exec($cmd));
      echo('abc');
    }
  }
  // 处理POST请求
  if($_SERVER['REQUEST_METHOD']==='POST'){
    $data=file_get_contents("php://input");
    $data=json_decode($data,true);
    
    // 检查password
    if($data['password']===$pwd){
      $cmd="cd $projpath && git pull";
      $rst=shell_exec($cmd);
      echo($rst);
      // echo('rd');
    }else{
      echo "err";
    }
  }
?>

